package jsr292.java.lang.invoke;


class ArrayUtils {
    private ArrayUtils() {
          // no instance
    }
    
    static Object[] copyOf(Object[] original, int newLength)  {
        Object[] array = new Object[newLength];
        System.arraycopy(original, 0, array, 0, Math.min(original.length, newLength));
        return array;
    }
    
    static MethodHandle[] copyOf(MethodHandle[] original, int newLength)  {
        MethodHandle[] array = new MethodHandle[newLength];
        System.arraycopy(original, 0, array, 0, Math.min(original.length, newLength));
        return array;
    }
    
    static Class<?>[] copyOf(Class<?>[] original, int newLength)  {
        Class<?>[] array = new Class<?>[newLength];
        System.arraycopy(original, 0, array, 0, Math.min(original.length, newLength));
        return array;
    }

    static Object[] copyOfRange(Object[] original, int from, int to) {
        int newLength = to - from;
        Object[] array = new Object[newLength];
        System.arraycopy(original, from, array, 0, Math.min(original.length - from, newLength));
        return array;
    }
    
    static Class<?>[] copyOfRange(Class<?>[] original, int from, int to) {
        int newLength = to - from;
        Class<?>[] array = new Class<?>[newLength];
        System.arraycopy(original, from, array, 0, Math.min(original.length - from, newLength));
        return array;
    }
}
